package per.hx.bs.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import per.hx.bs.constant.TopicRabbit;

/**
 * @author HuXing
 * @date 2018/4/26  12:21
 */
@Configuration
public class TopicRabbitConfig {

    @Bean
    TopicExchange exchange() {
        return new TopicExchange("topicExchange");
    }


    @Bean
    public Queue queueEmail() {
        return new Queue(TopicRabbit.EMAIL);
    }

    @Bean
    public Queue queueMessage() {
        return new Queue(TopicRabbit.MESSAGE);
    }

    @Bean
    Binding bindingExchangeEmail(Queue queueEmail, TopicExchange exchange) {
        return BindingBuilder.bind(queueEmail).to(exchange).with(TopicRabbit.EMAIL);
    }

    @Bean
    Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) {
        return BindingBuilder.bind(queueMessage).to(exchange).with(TopicRabbit.OTHER);
    }
}
